package com.activemanager.dashboard;

import java.io.InputStream;

import com.example.android.navigationdrawerexample.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

    public class SplashActivity extends Activity {

        ProgressBar bar;
        TextView label;
        Handler handler = new Handler();

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            
            ImageView imageView = (ImageView) findViewById(R.id.imageView1);
    		BitmapFactory.Options opt = new BitmapFactory.Options();
    		opt.inPreferredConfig = Bitmap.Config.RGB_565;
    		opt.inPurgeable = true;
    		opt.inInputShareable = true;
//    		InputStream is = getResources().openRawResource(
//    				R.drawable.flash_cover_540);
//    		Bitmap bit = BitmapFactory.decodeStream(is, null, opt);
//    		imageView.setImageBitmap(bit);
    		imageView.setBackgroundResource(R.drawable.flash_cover_540);
    		
            bar = (ProgressBar) findViewById(R.id.progressBar1);

            new Thread(new Runnable() {

                int i = 0;
                int progressStatus = 0;

                public void run() {
                    while (progressStatus < 100) {
                        progressStatus += doWork();
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        // Update the progress bar
                        handler.post(new Runnable() {
                            public void run() {
                                bar.setProgress(progressStatus);
                                i++;
                            }
                        });
                    }
                    Intent intent = new Intent(SplashActivity.this, H0Activity.class);
            		SplashActivity.this.startActivity(intent);
            		SplashActivity.this.finish();
                }
                private int doWork() {

                    return i * 10;
                 }

                }).start();         
            	
        }
    }